package com.gf.nams.controller.resolver;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver;

public class ContentExceptionResolver extends SimpleMappingExceptionResolver {

	
	private static final Logger logger = Logger.getLogger(ContentExceptionResolver.class);

    @Override
    protected ModelAndView doResolveException(HttpServletRequest request,
                                              HttpServletResponse response, Object handler, Exception ex) {

        proccessApiRequest(response,ex);

        return null;
    }

    private void proccessApiRequest(HttpServletResponse response, Exception ex) {
        response.setStatus(HttpServletResponse.SC_OK);
        response.setCharacterEncoding("UTF-8");
        response.setContentType("text/plain; charset=UTF-8");
        
        logger.error(ex.getMessage(),ex);
    }


}